package com.weiyi.mashangzhu.Roomer.Adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.weiyi.mashangzhu.Base.BaseListAdapter;
import com.weiyi.mashangzhu.R;
import com.weiyi.mashangzhu.Roomer.Bean.IntroInfo;


import java.util.List;

public class IntroAdapter extends BaseListAdapter<IntroInfo> {


    public IntroAdapter(Context context, List<IntroInfo> list) {
        super(context, list);
    }

    @Override
    public View initView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder;
        if (convertView == null) {
            convertView = View.inflate(mContext, R.layout.item_house_detail_intro_list, null);
            holder = new ViewHolder();
            holder.icon = (ImageView) convertView.findViewById(R.id.house_intro_icon);
            holder.title = (TextView) convertView.findViewById(R.id.house_intro_title);
            holder.content = (TextView) convertView.findViewById(R.id.house_intro_content);
            convertView.setTag(holder);
        } else {
            holder = (ViewHolder) convertView.getTag();
        }
        IntroInfo intro = mList.get(position);
        int icon = intro.getIcon() != 0 ? intro.getIcon() : 0;
        String title = intro.getTitle() != null ? intro.getTitle() : "";
        String content = intro.getContent() != null ? intro.getContent() : "";

        Glide.with(mContext).load(icon).into(holder.icon);
        holder.title.setText(title);
        holder.content.setText(content);

        return convertView;
    }

    private class ViewHolder {
        private ImageView icon;
        private TextView title;
        private TextView content;
    }
}
